home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / Mac F2C 1.2.2 / Mac F2C Documentation / INSTRUCTIONS (CodeWarrior) < prev    next >
Encoding:
Text File  |  1995-08-29  |  17.7 KB  |  390 lines  |  [TEXT/MMCC]

  1.         *************************************************
  2.         *************************************************
  3.  
  4.           INSTRUCTIONS FOR SETTING UP AND USING Mac F2C 
  5.  
  6.                 WITH METROWERKS CODEWARRIOR C/C++
  7.  
  8.         *************************************************
  9.         *************************************************
  10.  
  11.  
  12.  
  13. Before you can use the code produced by Mac F2C, you must set up and build 
  14. all of the required support libraries.  There are also special rules that 
  15. must be followed when using code produced by Mac F2C.  The process and 
  16. rules are slightly different for Symantec C/C++ or THINK C/C++ and for 
  17. CodeWarrior C/C++.  These instructions are for setting up Mac F2C for use 
  18. with Metrowerks CodeWarrior C/C++.  Refer to the documentation file 
  19. "Instructions (Symantec)" for instructions on how to set things up for use 
  20. with Symantec C/C++ or THINK C/C++.
  21.  
  22. USERS UPGRADING FROM VERSION 1.2:  The v1.2.2 upgrade has project files and 
  23. stationary files compatible with CodeWarrior v1.3 (from the CW7 CD).  If 
  24. you are still using CW6, you do not need this upgrade.  If you have 
  25. upgraded to CW7, you only need to replace the old CW6 stationary files with 
  26. the new CW7 stationary files included here.  In theory you do not need to 
  27. rebuild the support libraries (libI77 and libF77), because the CW6 versions 
  28. are supposed to work correctly with CW7.  Nevertheless, I recommend you 
  29. build CW7 versions of these libraries using the CW7 project files included 
  30. with Mac F2C v1.2.2.
  31.  
  32. USERS UPGRADING FROM VERSION 1.1 OR PRIOR:  You need to re-install ALL 
  33. libraries and project files, including main.c and f2c.h.  Both library 
  34. source code and the options settings in the various project files changed. 
  35.  
  36.  
  37. Please note that the source code and libraries provided are set up to use 
  38. with CodeWarrior v1.3 from the CW7 CD. 
  39.  
  40. IF YOU ARE STILL USING CODEWARRIOR V1.2 (CW6):  You can find CW6 versions 
  41. of all the project files and stationary files in the folder "CW6 Project 
  42. Files" located in the "CodeWarrior Support" folder.  Simply replace all the 
  43. project files and stationary files referred to in these instructions with 
  44. the corresponding files of the same name from the "CW6 Project Files" 
  45. folder.
  46.  
  47. To use earlier CodeWarrior releases with Mac F2C, contact Dirk Froehling 
  48. (dirk@gaga.maschinenbau.uni-dortmund.de), because a few workarounds and 
  49. additions are required.
  50.  
  51. The instructions here are broken into four sections:
  52.  
  53.     A.  Setting up Mac F2C
  54.     
  55.     B.  Verifying correct operation
  56.     
  57.     C.  Translating with Mac F2C
  58.     
  59.     D.  Using C code produced by Mac F2C
  60.     
  61.     
  62.     
  63. *****************************************************************************
  64.  
  65.  
  66. A.  SETTING UP Mac F2C
  67. **********************
  68.  
  69. Step 1:  BRING ALL THE LIBRARIES UP-TO-DATE
  70.  
  71. The libraries of the Mac F2C distribution come without binaries, so you have
  72. to build them according to the following algorithm. There are two versions
  73. of each library project, one for the 68K compiler and one for the PowerPC
  74. compiler. They are named with the usual extensions, 68K.µ and PPC.µ. You can
  75. use both versions or just one if you like (skip the instructions for either
  76. the 68K or PPC version).
  77.  
  78. If you are using CW6 vice CW7, replace all the project files and stationary 
  79. files referred to in these instructions with the corresponding files of the 
  80. same name found in the folder "CW6 Project Files" located in the 
  81. "CodeWarrior Support" folder.
  82.  
  83. FOR the project files:
  84.  
  85.         (1) "libI77.68K.µ"  in the "Mac F2C Libraries" folder
  86.         (2) "libF77.68K.µ"  in the "Mac F2C Libraries" folder
  87.         (3) "libI77.PPC.µ"  in the "Mac F2C Libraries" folder
  88.         (4) "libF77.PPC.µ"  in the "Mac F2C Libraries" folder
  89.         
  90. REPEAT the following steps:
  91.  
  92.     (a) Double-click on the project file.  
  93.     
  94.     (b) In the CW Environment's "Project" menu, select the 
  95.         "Make" command.  
  96.  
  97. END REPEAT
  98.  
  99.  
  100.  
  101. Step 2:  MOVE THINGS TO THE RECOMMENDED LOCATIONS
  102.  
  103. For easiest and smoothest operation, the support libraries and other 
  104. support files should be installed where the CodeWarrior C compiler can find 
  105. them easily.  I recommend you install Mac F2C libraries and support files 
  106. as follows:
  107.  
  108. (1) Drag the libraries "libI77.68K", "libF77.68K", "libI77.PPC" and
  109.     "libF77.PPC" you obtained by following the instructions of Step 1
  110.     from the folder "Mac F2C Libraries" to the folder "MacOS Support" 
  111.     in the "Metrowerks  C/C++ ƒ" folder that contains the CodeWarrior 
  112.     Environment.  I suggest you put them into their own folder inside 
  113.     the "MacOS Support" folder.  (CW6 doesn't have a "MacOS Support" 
  114.     folder, so simply place them inside the "Metrowerks  C/C++ ƒ" 
  115.     folder.)  You can delete the THINK files "libF77", "libI77a", and 
  116.     "libI77b" in the folder "Mac F2C Libraries" if you don't need them.
  117.     
  118. (2) The "For '(Project Stationary)'" located in the "CodeWarrior Specific 
  119.     Stuff" folder contains project stationary files that are used for 
  120.     compiling C and C++ code produced by Mac F2C.  Drag the project 
  121.     stationary files to the "(Project Stationary)" folder found in the 
  122.     "Metrowerks C/C++ ƒ" folder that contains the CodeWarrior C/C++ 
  123.     Environment.
  124.  
  125. (3) The "For 'Proj Stationery Support'" located in the "CodeWarrior 
  126.     Specific Stuff" folder contains code files ("f2c.h" and "main.c") 
  127.     that are needed to run C programs produced by Mac F2C.  Drag these 
  128.     two files to the 'Project Stationery Support' folder inside the 
  129.     "(Project Stationery)" folder inside the "Metrowerks C/C++ ƒ" folder 
  130.     that contains the CodeWarrior Environment.  (CW6 doesn't have a 
  131.     "Project Stationery Support" folder, so for CW6 place "f2c.h" and 
  132.     "main.c" inside the "Metrowerks C/C++ ƒ" folder, preferably in the 
  133.     same place as you put "libI77" and "libF77".)
  134.  
  135.  
  136.  
  137.  
  138.  
  139. *****************************************************************************
  140.  
  141.  
  142. B.  VERIFYING CORRECT OPERATION OF Mac F2C
  143. ******************************************
  144.  
  145. The folder "Test Project ƒ" contains the following files:
  146.  
  147. (1) "test.f" -- a sample FORTRAN program.
  148.  
  149. (2) "main.c" -- the main program required to run programs produced
  150.     by with Mac F2C.
  151.     
  152. (3) "f2c.h" -- an include file required to compile programs produced by 
  153.     Mac F2C.
  154.  
  155. (4) "test.c (Output)" -- what you should get when you translate 
  156.     the sample FORTRAN code files.
  157.     
  158. (5) "Test.68K.µ" and "Test.PPC.µ" -- CodeWarrior projects to run the sample
  159.     program. These serve as models for how to compile, link, and run C 
  160.     code produced by Mac F2C. 
  161.     
  162. (6) "test.c (C++ Output)" -- what you should get when you translate 
  163.     the sample FORTRAN code files and select the C++ output option.
  164.  
  165. (7) "Test++.68K.µ" and "Test++.PPC.µ" -- CodeWarrior projects to run the 
  166.     sample program when Mac F2C is used to produce C++ output. These serve 
  167.     as models for how to compile, link, and run C++ code produced by 
  168.     Mac F2C. 
  169.     
  170. (8) "Test.*.π" and "Test++.*.π" -- Symantec/THINK project files (not used)
  171.     
  172. Translate the sample FORTRAN program "Test.f" simply by dragging it onto 
  173. Mac F2C.  Do not change any of the options (use "Factory Defaults").  Once 
  174. you have done this you can compare it with "Test.c (sample)" file to verify 
  175. that you got the same thing.  If so, double click on the CodeWarrior 
  176. project "Test.68K.µ" or "Test.PPC.µ" and follow the same steps outlined in 
  177. the "Bringing Libraries Up-To-Date" section to bring the test project 
  178. up-to-date.  Run it to verify correct operation.
  179.  
  180. If you also plan to use Mac F2C C++ output with the Codewarrior, you can 
  181. run a second test to verify correct operation with the C++ compiler.  Start 
  182. Mac F2C and in the "C Options" dialog, select "C++ code".  Do not change 
  183. any of the other options.  Translate "Test.f".  Compare it with "Test.cp 
  184. (C++ Output)" to verify that you got the same thing.  If so, double click 
  185. on the CodeWarrior project "Test++.68K.µ" or "Test++.PPC.µ" and follow the 
  186. same steps outlined in the "Bringing Libraries Up-To-Date" section to bring 
  187. the test project up-to-date.  Run it to verify correct operation.
  188.  
  189.  
  190.  
  191.  
  192. *****************************************************************************
  193.  
  194.  
  195. C.  TRANSLATING FORTRAN PROGRAMS
  196. ********************************
  197.  
  198. You can use Mac F2C to translate FORTRAN to C using four methods:
  199.  
  200. (a) Start up Mac F2C and select the "Translate" command in the File menu.  
  201.     
  202. (b) Drag-&-drop a bunch of FORTRAN files onto Mac F2C.
  203.  
  204. (c) Use a scripting language (e.g., AppleScript) to send Mac F2C either an 
  205.     'open' command, an 'f2c' command, or a 'translate' command.  For more 
  206.     information on driving Mac F2C from a script see the instructions in 
  207.     the folder "Mac F2C AppleEvents".
  208.  
  209. (d) Use the MPW/ToolServer tools provided in the "MPW/ToolServer Tools"
  210.     folder inside the "CodeWarrior Specific Stuff" folder.  Please follow 
  211.     the instructions in the "ToolServer READ ME" and "MPW READ ME" files.
  212.      
  213. FORTRAN files must be TEXT files and *must* end in ".f" or ".F" (sorry, but 
  214. the ending is determined by the unix f2c kernel -- it rejects files handed 
  215. to it with any other endings).  The output file is the same name with a 
  216. ".c" extension if you selected C code for the output, or the same name with 
  217. a ".cp" extension if you selected C++ code for the output.
  218.  
  219. The first five items in the Options menu let you control the various 
  220. translation and code generation options.  If you check the "Make these the 
  221. new defaults" box before clicking the "OK" button, your option selections 
  222. will be saved in a Preference file and used again the next time you start 
  223. Mac F2C.
  224.  
  225. If you do not understand what an option means, check the balloon help.  The 
  226. help balloons provide more detailed explanations of what each option means.  
  227. They also explain why dimmed options are not available and what you can do 
  228. to make them available.
  229.  
  230. The last item in the Options menu ("Mac F2C Preferences…") lets you control 
  231. how Mac F2C operates.  This dialog lets you control:
  232.  
  233.     - How Mac F2C behaves after having been launched with a drag-&-drop.
  234.     
  235.     - Whether the "Advanced Options" dialog will have an edit text field 
  236.       that allows you to enter unix option switches directly.
  237.       
  238.     - The creator type for all of the output files (determines their icon).
  239.     
  240.     - Whether and how Mac F2C interacts with THINK and/or CodeWarrior.  If 
  241.       the notify option is checked, Mac F2C will attempt to touch the 
  242.       corresponding THINK or CodeWarrior project file after translating a 
  243.       FORTRAN file into C successfully.  If THINK/CodeWarrior is not running 
  244.       or if the file is not part of the current project, Mac F2C will fail 
  245.       silently.  If the make option is checked, then Mac F2C will also send 
  246.       a make (e.g., bring up to date) command to THINK/CodeWarrior.  If a 
  247.       group of FORTRAN files are translated at once (via a drag-&-drop or 
  248.       via an AppleScript), the make command is not sent until the last file 
  249.       is translated.  Again, Mac F2C fails silently if THINK or CodeWarrior 
  250.       can't do it.
  251.       
  252. As in the case of the other option dialogs, check the balloon help if you 
  253. do not understand what an option means.  
  254.        
  255.  
  256.  
  257.  
  258. *****************************************************************************
  259.  
  260.  
  261. D.  USING C CODE PRODUCED BY MAC F2C
  262. ************************************
  263.  
  264. The C code produced by Mac F2C has the following compile and link requirements:
  265.  
  266. 68K version:
  267.  
  268.     -   the header file "f2c.h"
  269.     -   the F2C libraries "libI77.68K" and "libF77.68K"
  270.     -   the CW libraries "ANSIFa(4i/8d)C.68K.Lib", "MathLib68K (4i/8d).Lib",
  271.         "SIOUX.68K.Lib", and "MacOS.lib"    
  272.     -   for C++ code only, the CW libraries "ANSIFa(4i/8d)C++.68K.Lib" and 
  273.         "CPlusPlus.Lib"
  274.     -   4-byte integers
  275.     -   8-byte doubles
  276.     -   far data
  277.     -   "Smart" code model
  278.  
  279.  
  280. PPC version:
  281.  
  282.     -   the header file "f2c.h"
  283.     -   the F2C libraries "libI77.PPC" and "libF77.PPC"
  284.     -   the CW libraries "ANSI C.PPC.Lib", "MWCRuntime.Lib", "Interface.Lib",
  285.         "SIOUX.PPC.Lib", and "MathLib"
  286.     -   for C++ code only, the CW library "ANSI C++.PPC.Lib"
  287.     
  288. In addition, if you compile a stand-alone FORTRAN program (instead of only some 
  289. FORTRAN subroutines) you must include "main.c" in your project.  This is 
  290. because the original main routine in the FORTRAN program becomes a function 
  291. that is called by main.c.  In addition, main.c performs a series of 
  292. initializations (primarily related to error catching) prior to executing 
  293. the main FORTRAN program.
  294.  
  295. The "For '(Project Stationary)'" and "For 'Proj Stationary Support'" 
  296. folders provided in the "CodeWarrior Specific Stuff" folder contain 
  297. everything you need to compile and run code produced by Mac F2C.  Copy the 
  298. project stationary files to the "(Project Stationary)" folder, and copy 
  299. "main.c" and "f2c.h" from the "For 'Proj Stationary Support'" to the 
  300. "Project Stationary Support" folder inside the "(Project Stationary)" 
  301. folder inside "Metrowerks C/C++ ƒ" folder.  To start a new project using 
  302. Mac F2C code, launch the CW 68K or PPC C compiler, select "New Project..." 
  303. and choose the appropriate Mac F2C project stationary, a name and a folder 
  304. for your project in the upcoming Standard File dialog.  Then add your code 
  305. files and bring everything up-to-date.  Use the "C" versions of project 
  306. stationary to work with C code generated by Mac F2C and the "C++" versions 
  307. of project stationary to work with C++ code generated by Mac F2C.  
  308.  
  309. If you get any error messages that CodeWarrior could not find "libI77", 
  310. "libF77", "main.c", or "f2c.h" it means that you did not place these in the 
  311. appropriate places.  Either move them appropriately or adjust the access 
  312. paths for your project using the CodeWarrior "Preferences..." dialog.
  313.  
  314. If you compile a FORTRAN subroutine or function that you want to call from 
  315. a C program, look at the output C code to see the appropriate calling 
  316. protocol.  You may or may not need to include the F2C support libraries 
  317. (libF77 and libI77).  In rare cases, you may also need to copy 
  318. some of the initialization code from "main.c" to your calling program.
  319.  
  320.  
  321. Please read the following section carefully if you intend to use Mac F2C
  322. with the 68K compiler (the PPC compiler doesn't give you any of the options
  323. mentioned, so there is nothing to consider):
  324.  
  325. As noted above, code produced by Mac F2C *MUST* be compiled with 4-byte 
  326. integers.  This requirement cannot be relaxed.  The other requirements 
  327. (8-byte doubles, far data) can sometimes be relaxed:
  328.  
  329.     -   IF you do not use doubles in any situation where their size 
  330.         relative to reals matters (e.g., if you do not use doubles in 
  331.         equivalence and common statements), then your code probably does
  332.         not require 8-byte doubles.  You need to verify this on a case-
  333.         by-case basis.
  334.         
  335.         This requirement exists because Mac F2C follows FORTRAN sizing 
  336.         rules when compiling FORTRAN code:  sizeof(real) == sizeof(integer) 
  337.         and sizeof(double) == 2*sizeof(real).  FORTRAN real is compiled as 
  338.         C float and FORTRAN double as C double, so doubles have to be 
  339.         8-bytes long for equivalence and common statements to be properly 
  340.         aligned.  There are a few other cases where the size of double 
  341.         variables matters; see AT&T Computing Science Technical Report 
  342.         No. 149 (included with Mac F2C) for a detailed discussion.
  343.         
  344.     -   IF you compile your program with the option "Local variables are 
  345.         automatic" and you do not have large static data structures, you 
  346.         *might* not need "Far Data".  You need to verify this on a case-
  347.         by-case basis.
  348.         
  349.         Mac F2C creates large static data structures for I/O.  If you create 
  350.         local variables in the global area (static instead of automatic) or 
  351.         if you have other static data, you will almost certainly require 
  352.         "Far Data".  The I/O data structures can be large enough that you may 
  353.         require "Far Data" for that reason alone.  
  354.  
  355.     -   The 68K project files are all set to use the "Smart" code model. That
  356.         means, the compiler generates a combination of the far and near (32 bit
  357.         and 16 bit) addressing types, using near when possible. Segments are
  358.         not limited to 32K of object code.
  359.         
  360.         I suggest to stick with this option, since the "Large" code model doesn't
  361.         usually give you advantages over "Smart", and "Small" requires a jump 
  362.         table for inter-segment jumps which has a negative effect on code size 
  363.         and speed. But you can try and put all files into one segment if your 
  364.         program is small enough and doesn't use much of the library code.  You 
  365.         need to verify this on a case-by-case basis.  If you are working with
  366.         very large FORTRAN programs, you may get a link error from Codewarrior
  367.         saying something to the effect that 16-bit offsets aren't enough to 
  368.         reach some function or other.  In this case you can simply select the 
  369.         "Large" code model to solve the problem.   
  370.         
  371. If you change the "8-byte doubles", "Smart", "Far Data" or "68881" options, 
  372. remember to also change them in all the Mac F2C libraries, specifically 
  373. "libI77.68K" and "libF77.68K", and include the appropriate ANSI library.  
  374. The standard ANSI library used in the F2C project files is 
  375. "ANSIFa(4i/8d)C.68K.Lib".  The 'Fa' stands for "Far Model" and the 
  376. arguments inside the braces show the compiler options (4-byte integers/ 
  377. 8-byte doubles).  For example, if you don't need 8-byte doubles, use 
  378. "ANSIFa(4i)C.68K.Lib"; or if you want direct 68881 support, use 
  379. "ANSIFa(4i/F/8d)C.68K.Lib".
  380.  
  381.  
  382. I urge all users to read the enclosed AT&T Computing Science Technical 
  383. Report No. 149.  Consider it your compiler and language reference 
  384. manual.  You can print the report by downloading it to any PostScript 
  385. printer.  You can use Apple's LaserWriter Utility application to do 
  386. this or you can use any of the many equivalent utilities.
  387.  
  388.  
  389.  
  390.